Skip to content

feat(cli): add --export and --import flags for plugin lists#21

Open
piekstra wants to merge 3 commits intomainfrom
piekstra/7-export-import-plugins
Open

feat(cli): add --export and --import flags for plugin lists#21
piekstra wants to merge 3 commits intomainfrom
piekstra/7-export-import-plugins

Conversation

@piekstra
Copy link
Contributor

[7]

Add CLI flags to export installed plugins to a JSON file and import them on another machine or project.

Summary

  • Add --export <file> / -e <file> flag to export installed plugins to JSON
  • Add --import <file> / -i <file> flag to import plugins from a JSON file
  • Export format includes plugin ID, scope, and enabled state
  • Import shows confirmation prompt listing plugins to install
  • Skip already-installed plugins during import

Export format

{
  "version": 1,
  "plugins": [
    {"id": "plugin@marketplace", "scope": "user", "enabled": true},
    {"id": "other@marketplace", "scope": "project", "enabled": false}
  ]
}

Test plan

  • Run cpm --export plugins.json and verify JSON file is created with correct format
  • Run cpm --import plugins.json and verify confirmation prompt appears
  • Verify skipped plugins are reported correctly
  • Run cpm --help and verify new flags are documented

Add CLI flags to export installed plugins to a JSON file and import
them on another machine or project.

Export format includes plugin ID, scope, and enabled state.
Import shows a confirmation prompt before installing missing plugins.

[7]
- Fix file permissions: use 0o600 instead of 0o644 (gosec G306)
- Reorder ExportFile struct for optimal memory alignment

[7]
The Claude CLI returns different JSON formats depending on the
--available flag:
- With --available: {installed: [...], available: [...]}
- Without --available: [...] (just installed plugins array)

This updates ListPlugins to parse both formats correctly.

[7]
@bojanrajkovic
Copy link
Contributor

I think this feature actually won't work very well without turning into a full blown package manager. 😂 Exporting needs to restore marketplaces, too, it gets out of sync too quickly, etc. I tried solving it and ended up throwing away the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments